// Purpose : In this page a doctor can view profile.
// Date    : 27 Sep, 2007
// Author  : Vinayak Singh Rathore
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using SiteManager;
public partial class DashBoard_MyProfile : System.Web.UI.Page
{
    protected string count="";// variable is use for assing number of view
    protected int doctorid; // doctor id
    protected int userType;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            // CODE COMMENTED AS DENTIST WERE NOT ABLE TO ACCESS THIS PAGE
            // DATE 18TH FEB 2008
            
            //localFunction drchk = new localFunction();
            //drchk.checkDoctorLogin(true);

            localFunction lfunction = new localFunction();
            if (Session["DoctorType"].ToString() == "Doctor")
            {
                lfunction.checkDoctorLogin(true);
                userType = 2;
            }
            else if (Session["DoctorType"].ToString() == "Dentist")
            {
                lfunction.checkDentistLogin(true);
                userType = 4;
            }
            else
                Response.Redirect(Session["strHttp"].ToString());

            SetProfileCounter();

            //if (Session["userID"] != null && !Session["userID"].ToString().Length .Equals(0) && Session["userType"].ToString() != "SiteUser")
            //{
                
            //    if ((Session["userType"].ToString() == "Doctor") && ((Convert.ToString(Session["DoctorType"]).Length == 0)))
            //        userType = 2;
            //     else if ((Session["userType"].ToString() == "Doctor") && (Convert.ToString(Session["DoctorType"]) == "Dentist"))
            //         userType = 4;
            //     doctorid = Convert.ToInt32(Session["userID"]);
            //    SetProfileCounter();
            //}
            //else
            //{
            //    Response.Redirect(Session["strHttp"]+ "default.aspx");
            //}
            
        }
    }
    /// <summary>
    ///  public void SetProfileCounter()
    /// This function execute when a user view profile of a doctor
    /// </summary>
    public void SetProfileCounter()
    {
        // Instance of manager class
        Manager objManager = new Manager(true,"ConnectionString");
        SqlDataReader objDataReader = null;
        objDataReader = objManager.ExecuteQuery("Select * from ProfileView where doctorId="+doctorid+"and DoctorType="+userType);
        if(objDataReader.HasRows)
        {
            objDataReader.Read();
            count=objDataReader["Views"].ToString();
        }
        objManager = null;
    }
}
